home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / ARCADE.ZIP / MS.EXE / lzh / ARC7_3.CHP < prev    next >
Encoding:
Text File  |  1993-06-15  |  11.0 KB  |  326 lines

  1. %
  2. #EF
  3. #T15,1,Chapter 7     Designing Space Attackers     Pg. 14
  4. #HS,1,4,80,25,11,1
  5. #C4,R5
  6.  
  7.                             ~W~IOperations On Objects~Y~I
  8.  
  9. Usually, the next step in program design is to define the allowable
  10. operations on each of the objects. This will enable us to determine the
  11. set of macros and functions that will make up the ~Sinterface into each file
  12. in the program.~s
  13.  
  14. #WN
  15. I have provided ~R~Imore operations ~Y~Ion objects than are used in Space
  16. Attackers. This is ~M~Inot usually advisable ~Y~Ibecause it increases program size
  17. unnecessarily. However, I have attempted to anticipate some of the needs
  18. you might have in using this code and written some extra macros and
  19. functions that you might find helpful.
  20.  
  21.  
  22. #WN
  23.                                 ~W~IA point~Y~I
  24.  
  25. Since the point type is a basic component of most of the more complex types
  26. in this game, we'll list the operations on a point first.
  27.  
  28. #WN
  29. %
  30. #EF
  31. #T15,1,Chapter 7     Designing Space Attackers     Pg. 15
  32. #HS,1,4,80,25,11,1
  33. #C4,R5
  34.                                  ~W~IFigure 7.3~Y~I
  35.                             Operations on a point
  36.  
  37.         1.      Set the point.
  38.         2.      Set the point's row.
  39.         3.      Set the point's column.
  40.         4.      Get the point's row.
  41.         5.      Get the point's column.
  42.  
  43.  
  44. #WN
  45. At this time we won't discuss the actual algorithms that will be used to
  46. implement the operations listed above. That will be done in the next
  47. chapter when we write the code.
  48.  
  49. #WP
  50. %
  51. #EF
  52. #T15,1,Chapter 7     Designing Space Attackers     Pg. 16
  53. #HS,1,4,80,25,11,1
  54. #C4,R5
  55.                              ~W~IThe character~Y~I
  56.  
  57. As previously stated, we will be consolidating the features that are
  58. common to both attackers and the defender so that we can reuse some of the
  59. code. The allowable operations on a character are shown in Figure 7.4,
  60. which begins on the next page.
  61.  
  62. #WP
  63. %
  64. #EF
  65. #T15,1,Chapter 7     Designing Space Attackers     Pg. 17
  66. #HS,1,4,80,25,11,1
  67. #C4,R5
  68.                               ~W~IFigure 7.4~Y~I
  69.                        Operations on a character
  70.  
  71.         1.      Set the character's position.
  72.         2.      Set the character's row
  73.         3.      Set the character's column.
  74.         4.      Set the character's bitmap.
  75.         5.      Set the height and width of the character's bitmap.
  76.         6.      Set the character's bullet.
  77.         7.      Set the row and column of the character's bullet.
  78.         8.      Set the direction of the character's bullet.
  79.         9.      Set the color of the character's bullet.
  80.         10.     Tell the character whether or not it has a bullet.
  81.         11.     Tell the character whether it's alive or dead.
  82.         12.     Set the character's move increment.
  83.         13.     Get the character's row
  84.         14.     Get the character's column.
  85.         15.     Get the character's bitmap.
  86. #WP
  87. %
  88. #EF
  89. #T15,1,Chapter 7     Designing Space Attackers     Pg. 18
  90. #HS,1,4,80,25,11,1
  91. #C4,R5
  92.                           ~W~IFigure 7.4 (cont)~Y~I
  93.                        Operations on a character
  94.  
  95.         16.     Get the height and width of the character's bitmap.
  96.         17.     Get the character's bullet.
  97.         18.     Get the row and column of the character's bullet.
  98.         19.     Get the direction of the character's bullet.
  99.         20.     Ask the character if it has a bullet.
  100.         21.     Get the color of the character's bullet.
  101.         22.     Ask the character whether it's alive or dead.
  102.         23.     Get the character's move increment.
  103.  
  104.  
  105. #WN
  106. Notice that some of the operations on a character are the same as the
  107. operations on a point. That's because the member ~W~Icurrent_position ~Y~Iin the
  108. character is of type point. The operations on ~W~Icurrent_position~Y~I, such as
  109. setting the row of the upper left corner of the bitmap, will be
  110. implemented by just calling the appropriate point operation, such as
  111. ~W~Iset_point_row()~Y~I.
  112.  
  113. #WP
  114. %
  115. #EF
  116. #T15,1,Chapter 7     Designing Space Attackers     Pg. 19
  117. #HS,1,4,80,25,11,1
  118. #C4,R5
  119.  
  120.                                 ~W~IA bullet~Y~I
  121.  
  122. The allowable operations on a bullet are shown in Figure 7.5. Like a
  123. character, a bullet will "inherit" some of the point operations because it
  124. has a member of type point.
  125.  
  126. #WP
  127. %
  128. #EF
  129. #T15,1,Chapter 7     Designing Space Attackers     Pg. 20
  130. #HS,1,4,80,25,11,1
  131. #C4,R5
  132.  
  133.                                 ~W~IFigure 7.5~Y~I
  134.                           Operations on a bullet
  135.  
  136. ~W~I        1.      Set the bullet's position.
  137.         2.      Set the row of the bullet.
  138.         3.      Set the column of the bullet.
  139.         4.      Tell the bullet whether or not it exists.
  140.         5.      Set the color of the bullet.
  141.         6.      Set the direction of the bullet.
  142.         7.      Get the row of the bullet.
  143.         8.      Get the col of the bullet.
  144.         9.      Ask the bullet if it exists.
  145.         10.     Get the color of the bullet.
  146.         11.     Get the direction of the bullet.
  147. ~Y~I        12.     Draw the bullet.
  148.         13.     Erase the bullet.
  149.         14.     Move the bullet.
  150.         15.     Test to see if the bullet has hit something.
  151.  
  152. #BO,4,20,78,23,7,1,0,2,15,5
  153. The first eleven operation on a bullet are simple enough to be
  154. implemented as macros.
  155.  
  156. #C4,R5
  157.  
  158.                                 ~W~IFigure 7.5~Y~I
  159.                           Operations on a bullet
  160.  
  161.         1.      Set the bullet's position.
  162.         2.      Set the row of the bullet.
  163.         3.      Set the column of the bullet.
  164.         4.      Tell the bullet whether or not it exists.
  165.         5.      Set the color of the bullet.
  166.         6.      Set the direction of the bullet.
  167.         7.      Get the row of the bullet.
  168.         8.      Get the col of the bullet.
  169.         9.      Ask the bullet if it exists.
  170.         10.     Get the color of the bullet.
  171.         11.     Get the direction of the bullet.
  172. ~W~I        12.     Draw the bullet.
  173.         13.     Erase the bullet.
  174.         14.     Move the bullet.
  175.         15.     Test to see if the bullet has hit something.
  176. ~Y~I
  177.  
  178. #BO,4,7,78,9,7,1,0,2,15,5
  179. Operations 12-15 will be written as functions.
  180.  
  181. #WP
  182. %
  183. #EF
  184. #T15,1,Chapter 7     Designing Space Attackers     Pg. 21
  185. #HS,1,4,80,25,11,1
  186. #C4,R5
  187.                               ~W~IThe player~Y~I
  188.  
  189. The image of the player will be a tank-like gun that we can move across
  190. the bottom of the screen. It must also be able to fire at the attackers.
  191. Figure 7.6 shows the allowable operations on a player.
  192.  
  193.  
  194.                                ~W~IFigure 7.6~Y~I
  195.                     Allowable operations on a player
  196.  
  197.         1.      Set the player's position.
  198.         2.      Set the player's row
  199.         3.      Set the player's column.
  200.         4.      Set the player's direction.
  201.         5.      Set the player's bitmap.
  202.         6.      Set the height and width of the player's bitmap.
  203.         7.      Set the player's bullet.
  204.         8.      Set the row and column of the player's bullet.
  205.         9.      Set the direction of the player's bullet.
  206. #WP
  207. %
  208. #EF
  209. #T15,1,Chapter 7     Designing Space Attackers     Pg. 22
  210. #HS,1,4,80,25,11,1
  211. #C4,R5
  212.                            ~W~IFigure 7.6 (cont)~Y~I
  213.                     Allowable operations on a player
  214.  
  215.         10.     Set the color of the player's bullet.
  216.         11.     Tell the player whether it's alive or dead.
  217.         12.     Set the player's move increment.
  218.         13.     Get the player's row
  219.         14.     Get the player's column.
  220.         15.     Get the player's direction.
  221.         16.     Get the player's bitmap.
  222.         17.     Get the height and width of the player's bitmap.
  223.         18.     Get the player's bullet.
  224.         19.     Get the row and column of the player's bullet.
  225.         20.     Get the direction of the player's bullet.
  226.         21.     Get the color of the player's bullet.
  227.         22.     Ask the player whether it's alive or dead.
  228.         23.     Get the player's move increment.
  229. #WP
  230. %
  231. #EF
  232. #T15,1,Chapter 7     Designing Space Attackers     Pg. 23
  233. #HS,1,4,80,25,11,1
  234. #C4,R5
  235.                            ~W~IFigure 7.6 (cont)~Y~I
  236.                     Allowable operations on a player
  237.  
  238.         24.     Initialize the player.
  239.         25.     Draw the player.
  240.         26.     Move the player.
  241.         27.     Shoot the player's gun.
  242.  
  243. #WN
  244. Operations 1-23 will be done with macros. The rest will need to be
  245. implemented as functions.
  246.  
  247. #WP
  248. %
  249. #EF
  250. #T15,1,Chapter 7     Designing Space Attackers     Pg. 24
  251. #HS,1,4,80,25,11,1
  252. #C4,R5
  253.  
  254.                              ~W~IThe attacker~Y~I
  255.  
  256. We also need to know what operations are valid on an attacker. As with
  257. the operations on a player, some of the attacker operations will be
  258. implemented as macros and some will be written as functions. Figure 7.7
  259. shows the allowable operations on an attacker.
  260.  
  261. #WP
  262. %
  263. #EF
  264. #T15,1,Chapter 7     Designing Space Attackers     Pg. 25
  265. #HS,1,4,80,25,11,1
  266. #C4,R5
  267.  
  268.                                 ~W~IFigure 7.7~Y~I
  269.                          Operations on an Attacker
  270.  
  271.         1.      Set the attacker's position.
  272.         2.      Set the attacker's row
  273.         3.      Set the attacker's column.
  274.         4.      Set the attacker's direction.
  275.         5.      Tell the attacker whether or not it's in a position to
  276.                 shoot.
  277.         6.      Set the attacker's bitmap.
  278.         7.      Set the height and width of the attacker's bitmap.
  279.         8.      Set the attacker's bullet.
  280.         9.      Set the row and column of the attacker's bullet.
  281.         10.     Set the direction of the attacker's bullet.
  282.         11.     Set the color of the attacker's bullet.
  283.         12.     Tell the attacker whether or not it has a bullet.
  284.         13.     Tell the attacker whether it's alive or dead.
  285.  
  286. #WP
  287. %
  288. #EF
  289. #T15,1,Chapter 7     Designing Space Attackers     Pg. 26
  290. #HS,1,4,80,25,11,1
  291. #C4,R5
  292.                             ~W~IFigure 7.7 (cont)~Y~I
  293.                          Operations on an Attacker
  294.  
  295.         14.     Set the attacker's move increment.
  296.         15.     Get the attacker's row
  297.         16.     Get the attacker's column.
  298.         17.     Get the attacker's direction.
  299.         18.     Get the attacker's bitmap.
  300.         19.     Get the height and width of the attacker's bitmap.
  301.         20.     Get the attacker's bullet.
  302.         21.     Get the row and column of the attacker's bullet.
  303.         22.     Get the direction of the attacker's bullet.
  304.         23.     Ask the attacker if it has a bullet.
  305.         24.     Get the color of the attacker's bullet.
  306.         25.     Ask the attacker whether it's alive or dead.
  307. #WP
  308. %
  309. #EF
  310. #T15,1,Chapter 7     Designing Space Attackers     Pg. 27
  311. #HS,1,4,80,25,11,1
  312. #C4,R5
  313.                             ~W~IFigure 7.7 (cont)~Y~I
  314.                          Operations on an Attacker
  315.  
  316.         26.     Get the attacker's move increment.
  317.         27.     Initialize the attacker.
  318.         28.     Draw the attacker.
  319.         29.     Move the attacker.
  320.         30.     Shoot the attacker's gun.
  321.         31.     Ask the attacker whether or not it's in a position to
  322.                 shoot.
  323.  
  324. #WP
  325. #X
  326.